<style lang="scss">
.test-echarts-to {
  height: 400px;
  width: 100%;
}
</style>

<template>
  <div class="test-echarts-to" id="test-to"></div>
</template>

<script>
import echarts from "echarts";
export default {
  data() {
    return {
      name: "test-to"
    };
  },
  created() {
    this.$nextTick(function() {
      this.drow("test-to");
    });
  },
  methods: {
    drow(id) {
      this.charts = echarts.init(document.getElementById(id));
      this.charts.setOption({
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)",
          show: true
        },
        legend: {
          orient: "horizontal",
          x: "center",
          data: ["高中及以下", "研究生", "本科", "专科"],
          y: "bottom",
          textStyle: {
            color: "rgb(255, 255, 255)"
          }
        },
        toolbox: {
          show: false,
          feature: {
            mark: {
              show: true
            },
            dataView: {
              show: true,
              readOnly: true
            },
            restore: {
              show: true
            },
            saveAsImage: {
              show: true
            }
          }
        },
        calculable: true,
        series: [
          {
            name: "人数（人）",
            type: "pie",
            radius: ["50%", "70%"],
            itemStyle: {
              normal: {
                label: {
                  show: true
                },
                labelLine: {
                  show: true
                }
              },
              emphasis: {
                label: {
                  show: true,
                  position: "center",
                  textStyle: {
                    fontSize: "30",
                    fontWeight: "bold"
                  }
                }
              }
            },
            data: [
              {
                value: 128,
                name: "高中及以下"
              },
              {
                value: 9,
                name: "研究生"
              },
              {
                value: 21,
                name: "本科"
              },
              {
                value: 23,
                name: "专科"
              }
            ]
          }
        ],
        title: {
          text: "工作人员学历统计图",
          x: "center",
          textStyle: {
            color: "rgb(255, 255, 255)",
            fontSize: 15
          }
        },
        color: [
          "rgb(214, 81, 255)",
          "rgb(255, 212, 0)",
          "#32cd32",
          "#ff6347",
          "#32cd32",
          "#6495ed",
          "#ff69b4",
          "#87cefa",
          "#cd5c5c",
          "rgb(252, 161, 5)",
          "#40e0d0",
          "#1e90ff",
          "#ff6347",
          "#7b68ee",
          "#00fa9a",
          "rgb(255, 212, 0)",
          "#6699FF",
          "#ff6666",
          "#3cb371",
          "#b8860b",
          "#30e0e0"
        ]
      });
    }
  }
};
</script>


